package com.cnap.multiclouldmgmt.model.scale.group;

import cn.hutool.core.util.IdUtil;
import com.cnap.multiclouldmgmt.model.scale.db.ScalingGroupPO;
import com.cnap.multiclouldmgmt.model.scale.policy.ScalingDeletePolicyEnum;
import com.cnap.multiclouldmgmt.model.scale.validator.EnumCheck;

import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;

/**
 * <类文件描述>
 *
 * @author xc
 **/
public class ScalingGroupDTO {
    //集群名称
    @NotNull(message = "集群名称不能为空")
    private String clusterName;
    //云商名称
    @NotNull(message = "云商名称不能为空")
    private String provider;
    // 账户名称
    private String accountName;
    //标签
    private String label;
    //删除策略
    @EnumCheck(enumClass = ScalingDeletePolicyEnum.class, message = "删除策略错误")
    private String deletePolicy;
    //分组名称
    @NotNull(message = "分组名称不能为空")
    private String groupName;
    private int maxNum;
    private int expectNum;
    @Min(value = 1, message = "最小值为1")
    private int minNum;
    @NotNull(message = "配置信息不能为空")
    private String configId;

    /**
     * get
     *
     * @return AccountName
     */
    public String getAccountName() {
        return accountName;
    }

    /**
     * set
     *
     * @param accountName accountName
     */
    public void setAccountName(String accountName) {
        this.accountName = accountName;
    }

    /**
     * get
     *
     * @return ClusterName
     */
    public String getClusterName() {
        return clusterName;
    }

    /**
     * set
     *
     * @param clusterName clusterName
     */
    public void setClusterName(String clusterName) {
        this.clusterName = clusterName;
    }

    /**
     * get
     *
     * @return Provider
     */
    public String getProvider() {
        return provider;
    }

    /**
     * set
     *
     * @param provider provider
     */
    public void setProvider(String provider) {
        this.provider = provider;
    }

    /**
     * get
     *
     * @return Label
     */
    public String getLabel() {
        return label;
    }

    /**
     * set
     *
     * @param label label
     */
    public void setLabel(String label) {
        this.label = label;
    }

    /**
     * get
     *
     * @return DeletePolicy
     */
    public String getDeletePolicy() {
        return deletePolicy;
    }

    /**
     * set
     *
     * @param deletePolicy deletePolicy
     */
    public void setDeletePolicy(String deletePolicy) {
        this.deletePolicy = deletePolicy;
    }

    /**
     * get
     *
     * @return GroupName
     */
    public String getGroupName() {
        return groupName;
    }

    /**
     * set
     *
     * @param groupName groupName
     */
    public void setGroupName(String groupName) {
        this.groupName = groupName;
    }

    /**
     * get
     *
     * @return MaxNum
     */
    public int getMaxNum() {
        return maxNum;
    }

    /**
     * set
     *
     * @param maxNum maxNum
     */
    public void setMaxNum(int maxNum) {
        this.maxNum = maxNum;
    }

    /**
     * get
     *
     * @return ExpectNum
     */
    public int getExpectNum() {
        return expectNum;
    }

    /**
     * set
     *
     * @param expectNum expectNum
     */
    public void setExpectNum(int expectNum) {
        this.expectNum = expectNum;
    }

    /**
     * get
     *
     * @return MinNum
     */
    public int getMinNum() {
        return minNum;
    }

    /**
     * set
     *
     * @param minNum minNum
     */
    public void setMinNum(int minNum) {
        this.minNum = minNum;
    }

    /**
     * get
     *
     * @return ConfigId
     */
    public String getConfigId() {
        return configId;
    }

    /**
     * set
     *
     * @param configId configId
     */
    public void setConfigId(String configId) {
        this.configId = configId;
    }

    @Override
    public String toString() {
        return "ScalingGroupDTO{" +
                "clusterName='" + clusterName + '\'' +
                ", label='" + label + '\'' +
                ", deletePolicy='" + deletePolicy + '\'' +
                ", groupName='" + groupName + '\'' +
                ", maxNum=" + maxNum +
                ", expectNum=" + expectNum +
                ", minNum=" + minNum +
                ", configId='" + configId + '\'' +
                '}';
    }

    /**
     * 转换成po
     *
     * @return po
     */
    public ScalingGroupPO toPO() {
        ScalingGroupPO po = new ScalingGroupPO();
        po.setId(IdUtil.simpleUUID());
        po.setStatus(ScalingGroupStatusEnum.INIT.getStatus());
        po.setClusterName(this.clusterName);
        po.setProvider(this.provider);
        po.setLabel(this.label);
        po.setDeletePolicy(this.deletePolicy);
        po.setGroupName(this.groupName);
        po.setMaxNum(this.maxNum);
        po.setExpectNum(this.expectNum);
        po.setMinNum(this.minNum);
        po.setConfigId(this.configId);

        po.setAccountName(this.accountName);

        return po;
    }
}
